package com.xx.doublexchat.common.chat.dao;

import com.xx.doublexchat.common.chat.domain.entity.Message;
import com.xx.doublexchat.common.chat.mapper.MessageMapper;
import com.xx.doublexchat.common.chat.service.IMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 消息表 服务实现类
 * </p>
 *
 * @author xiaoXuan
 * @since 2024-02-29
 */
@Service
public class MessageDao extends ServiceImpl<MessageMapper, Message> implements IMessageService {
    /**
     * 获取回复消息数量
     * @param roomId
     * @param fromId
     * @param toId
     * @return
     */
    public Integer getGapCount(Long roomId, Long fromId, Long toId) {
        return lambdaQuery()
                .eq(Message::getRoomId, roomId)
                .gt(Message::getId, fromId)
                .le(Message::getId, toId)
                .count();
    }
}
